package com.mjx.algorithm.oj;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 求最大cycle length问题
 * Created by meijingxiang on 2017/2/10.
 */
public class problem1055 {
    public static void main(String[] args) {
        int number1, number2;
        int min,max;
        Map<Integer,Integer> map = new HashMap<Integer, Integer>();
        Scanner scanner = new Scanner(System.in);
        while (true){
            String s = scanner.nextLine();
            String[] temp = s.split(" ");
            number1 = Integer.parseInt(temp[0]);
            number2 = Integer.parseInt(temp[1]);
            min = Math.min(number1, number2);
            max = Math.max(number1, number2);
            int maxLength = 0;
            for (int i = min ; i <= max; i++) {
                int length;
                if (map.get(i) == null){
                    length = getLength(i);
                    map.put(i,length);
                }
                else {
                    length = map.get(i);
                }
                if (i == min) {
                    maxLength = length;
                    continue;
                }
                if (length > maxLength)
                    maxLength = length;
            }
            System.out.println(number1+" "+number2+" "+maxLength);
        }
    }

    private static int getLength(int num){
        int length = 1;
        while (true){
            if (num == 1)
                break;
            //如果是奇数
            if (num % 2 != 0){
                num = 3 * num + 1;
            }
            //如果是偶数
            else {
                num = num / 2;
            }
            length++;

        }
        return length;
    }
}
